package com.gouaixin.bee.beeframework2.activity;

import android.app.Activity;
import android.content.Context;
import android.os.Bundle;
import android.view.View;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.TextView;

import com.ab.util.AbToastUtil;
import com.gouaixin.bee.beeframework2.R;
import com.gouaixin.bee.beeframework2.bean.USER;

import cn.bmob.v3.BmobUser;
import cn.bmob.v3.listener.UpdateListener;

/**
 * Created by Administrator on 2015/3/10.
 */
//更新昵称界面
public class B20_gengxinNichengActivity extends Activity {
    Context context=B20_gengxinNichengActivity.this;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.b20_gengxinicheng);
        
        initHead();
        initContent();

    }

    /***
     * 内容区域的监听
     */
    TextView nicheng;
    TextView queding;



    private void initContent() {
        nicheng= (EditText) findViewById(R.id.nicheng);

        queding= (TextView) findViewById(R.id.queding);

        queding.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                String mNicheng=nicheng.getText().toString();

//                AbToastUtil.showToast(context,"更新昵称功能正在开发中：昵称="+mNicheng);


                USER myuser = BmobUser.getCurrentUser(context, USER.class);
                String name=nicheng.getText().toString();
                myuser.setName(name);
                myuser.update(context, new UpdateListener() {
                    @Override
                    public void onSuccess() {
                        AbToastUtil.showToast(context, "更新昵称成功");
                        finish();
                    }


                    @Override
                    public void onFailure(int i, String s) {

                    }
                });
            }
        });

    }

    /***
     * 头部的监听
     */
    private void initHead() {
        //顶部
        ImageView back;//返回
        TextView title;//标题
        TextView right;//右边



        back= (ImageView) findViewById(R.id.back);
        title= (TextView) findViewById(R.id.title);
        right= (TextView) findViewById(R.id.right);



        back.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                finish();
            }
        });

    }
}
